<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Fit Layout</title>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
    <script src="../../../scripts/jquery.min.js"></script>
    <script src="../../../scripts/miniui/miniui.js"></script>
    <link href="../../../scripts/miniui/themes/default/miniui.css" rel="stylesheet">
    <link href="../../../scripts/miniui/themes/icons.css" rel="stylesheet">
    <link href="../../../scripts/miniui/themes/pure/skin.css" rel="stylesheet">
    <script src="../../../scripts/core.js"></script>
    <script src="../../../data/export.js"></script>

</head>
<body>
<style type="text/css">
    html, body {
        margin: 0;
        padding: 0;
        border: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
</style>
<mini-toolbar style="width:100%;border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <a class="mini-button" iconCls="icon-add" onclick="lock()" plain="true" tooltip="封号...">封号</a>
                <a class="mini-button" iconCls="icon-remove" onclick="unlock()" plain="true">解封</a>
                <a class="mini-button" iconCls="icon-cancel" onclick="unBind()" plain="true">解绑</a>
                <a class="mini-button" iconCls="icon-search" onclick="openShare()" plain="true">分享信息</a>
                <a class="mini-button" iconCls="icon-search" onclick="openCoinLst()" plain="true">查看加密币数量</a>
                <a class="mini-button" iconCls="icon-unlock" onclick="setInner()" plain="true">踢下排行榜</a>
                <a class="mini-button" iconCls="icon-sort" onclick="canRank()" plain="true">上排行榜</a>
                <a class="mini-button" iconCls="icon-download" onclick="openIp()" plain="true">查询IP</a>
                <a class="mini-button" iconCls="icon-search" onclick="getShare()" plain="true">查询个人名下邀请者</a>
                <a class="mini-button" iconCls="icon-search" onclick="addInvite()" plain="true">添加邀请者</a>
            </td>

        </tr>
        <tr>
            <td>
                注册时间从<input class="mini-datepicker" id="start"/>到
                <input class="mini-datepicker" id="end"/>
                是否充值:
                <input class="mini-combobox" id="chargeType" showNullItem="true"
                       style="width:150px;"
                       textField="text"
                       url="../../../data/chargeType.js"
                       valueField="id"/>
                广告渠道:
                <input class="mini-combobox" id="adChannel" showNullItem="true"
                       style="width:150px;"
                       textField="text"
                       valueField="id"/>
                排序:
                <input class="mini-combobox" id="orderType" showNullItem="true"
                       style="width:150px;"
                       textField="text"
                       url="../../../data/infoOrderType.js"
                       valueField="id"/>

            </td>
            <td style="white-space:nowrap;">
                <input class="mini-textbox" emptyText="关键字" id="key" onenter="onKeyEnter" style="width:150px;"/>
                <a class="mini-button" onclick="search()">查询</a>
            </td>
        </tr>
    </table>
</mini-toolbar>
<!--撑满页面-->
<div class="mini-fit">

    <mini-datagrid _dataField="data111" allowCellEdit="true" allowCellSelect="true"
                   allowResize="true"
                   allowSortColumn="false" class="mini-datagrid"
                   id="datagrid1"
                   idField="id" multiSelect="false"
                   pageSize="60" showSortIcon="true"
                   sizeList="[20,30,50,100,500,7000]"
                   style="width:100%;height:100%;"
                   url="/cmsapi/business/getAllUserInfo"
    >
        <columns>
            <column type="indexcolumn"></column>
            <column field="country" width="100">国家
            </column>
            <column field="nick" width="100">昵称
            </column>
            <column field="tonVal" visible="true" width="100">抽奖ton余额
            </column>
            <column field="usdVal" visible="true" width="100">USDT余额
            </column>


            <column dateFormat="yyyy-MM-dd HH:mm:ss" field="regTime" width="150">注册时间
            </column>
            <column dateFormat="yyyy-MM-dd HH:mm:ss" field="lastOfflineTime" width="150">最后离线时间
            </column>


            <column field="starNum" width="100">星星充值

            </column>

            <column field="tonNum" width="100">ton充值

            </column>
            <column field="btcVal" width="100">比特币余额

            </column>


            <column field="aiCoin" width="100">PPK币
            </column>
            <column field="adChannel" width="100">广告渠道
            </column>

            <column field="inviteNum" width="100">邀请人数
            </column>
            <column field="shareId" width="100">分享人
            </column>
            <column field="userId" name="userId" width="150">用户id
            </column>
            <column field="isLock" width="100">封号
            </column>
            <column field="innerType" width="100">内部号
            </column>
            <column field="openId" visible="true" width="100">openId
            </column>

            <column field="clickNum" width="100">点击次数

            </column>
            <column field="lv" width="100">等级

            </column>
            <column field="tronAddress" width="100">波场钱包地址

            </column>
            <column field="tonAddress" width="100">ton钱包地址

            </column>
            <column field="bscAddress" width="100">bsc钱包地址

            </column>
        </columns>
    </mini-datagrid>

</div>

<script type="text/javascript">

    var auth = GetParams()
    mini.parse();


    var grid = mini.get("datagrid1");
    grid.setAjaxOptions({
        headers: {"userId": auth.userId, "token": auth.token}
    });
    grid.on("drawcell", function (e) {
        var record = e.record,
            column = e.column,
            field = e.field,
            value = e.value;


    });
    grid.load();

    // 页面完全加载完成（包括图片等资源）
    $(window).on("load", async function () {
        var adChannel = mini.get("adChannel");
        const tokenResp = await fetch("/cmsapi/business/getAdChannel", {
            method: 'POST',
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json'
        });
        const sysResp = await tokenResp.json();
        adChannel.setData(sysResp)
    });

    async function lock() {

        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];
        $.ajax({
            url: "/cmsapi/business/lockAccount",
            data: mini.encode({
                "userId": row.userId,
                "lock": 1
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                grid.reload();
                var resp = mini.decode(text);
                if (resp.code == 200) {
                    mini.alert("封号成功")
                }

            },
            error: function (jqXHR, textStatus, errorThrown) {

            }
        });
    }

    function exportData() {
        mini.mask({
            el: document.body,
            cls: 'mini-mask-loading',
            html: '加载中...'
        });
        var key = mini.get("key").getValue();
        var obj = mini.get("adChannel");
        var order = mini.get("orderType");
        var recharge = mini.get("chargeType");
        var sizeType = mini.get("sizeType").getValue();

        var start = mini.get("start").getValue();
        var end = mini.get("end").getValue();
        $.ajax({
            url: "/cmsapi/business/getAllUserInfo",
            data: mini.encode({
                targetUserId: key,
                adChannel: obj.getValue(),
                orderType: order.getValue(),
                charge: recharge.getValue(),
                startTime: start === "" ? null : start.toISOString(),
                endTime: end === "" ? null : end.toISOString(),
                pageIndex: 0,
                pageSize: sizeType
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                var resp = mini.decode(text);
                gridToCSV(grid, resp.data, "用户数据")
                mini.unmask(document.body);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });

    }

    function openIp() {

        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        mini.open({
            targetWindow: window,
            url: "UserIp.html?userId=" + auth.userId + "&token=" + auth.token + "&targetUserId=" + row.userId,
            title: "新增",
            width: 1024,
            height: 800,
            onload: function () {

            },
            ondestroy: function (action) {

            }
        });
    }

    function addInvite() {

        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        mini.open({
            targetWindow: window,
            url: "AddInviteNumCfg.html?userId=" + auth.userId + "&token=" + auth.token + "&targetUserId=" + row.userId,
            title: "新增",
            width: 1024,
            height: 800,
            onload: function () {

            },
            ondestroy: function (action) {

            }
        });
    }

    function openShare() {

        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        mini.open({
            targetWindow: window,
            url: "Invite.html?userId=" + auth.userId + "&token=" + auth.token + "&targetUserId=" + row.userId,
            title: "新增",
            width: 1024,
            height: 800,
            onload: function () {

            },
            ondestroy: function (action) {

            }
        });
    }

    function openCoinLst() {

        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        mini.open({
            targetWindow: window,
            url: "UserCoinLst.html?userId=" + auth.userId + "&token=" + auth.token + "&targetUserId=" + row.userId,
            title: "新增",
            width: 1024,
            height: 800,
            onload: function () {

            },
            ondestroy: function (action) {

            }
        });
    }

    function unlock() {
        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        $.ajax({
            url: "/cmsapi/business/lockAccount",
            data: mini.encode({
                "userId": row.userId,
                "lock": 0
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                grid.reload();
                var resp = mini.decode(text);
                if (resp.code == 200) {
                    mini.alert("解封成功")
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
    }

    function setInner() {
        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        $.ajax({
            url: "/cmsapi/business/setInner",
            data: mini.encode({
                "userId": row.userId,
                "lock": 0
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                grid.reload();
                var resp = mini.decode(text);
                if (resp.code == 200) {
                    mini.alert("下榜")
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
    }

    function canRank() {
        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        $.ajax({
            url: "/userinfo/canRank",
            data: mini.encode({
                "userId": row.userId,
                "lock": 0
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                grid.reload();
                var resp = mini.decode(text);
                if (resp.code == 200) {
                    mini.alert("上榜")
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
    }

    function unBind() {
        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];

        $.ajax({
            url: "/cmsapi/business/unBindAccount",
            data: mini.encode({
                "userId": row.userId
            }),
            type: "post",
            headers: {"userId": auth.userId, "token": auth.token},
            contentType: 'application/json',
            success: function (text) {
                grid.reload();
                var resp = mini.decode(text);
                if (resp.code == 200) {
                    mini.alert("解绑成功")
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
    }


    function search() {
        var key = mini.get("key").getValue();
        var obj = mini.get("adChannel");
        var order = mini.get("orderType");
        var recharge = mini.get("chargeType");

        var start = mini.get("start");
        var end = mini.get("end");
        grid.load({
            targetUserId: key,
            adChannel: obj.getValue(),
            orderType: order.getValue(),
            charge: recharge.getValue(),
            startTime: start == null ? null : mini.formatDate(start.getValue(), "yyyy-MM-dd"),
            endTime: end == null ? null : mini.formatDate(end.getValue(), "yyyy-MM-dd")
        });
    }

    function getShare() {
        if (grid.getSelecteds().length == 0) return;
        var row = grid.getSelecteds()[0];


        grid.load({
            inviteId: row.userId,

        });
    }


</script>

</body>
</html>